package main

import (
	"github.com/hajimehoshi/ebiten"
	"image/color"
	"image/png"
	"log"
	"os"
)

func DrawBackGround(screen *ebiten.Image){
	//  背景颜色
	screen.Fill(color.RGBA{78, 192, 202,255})
	//  绘制地板
	f1, err := os.Open("imgs/ground.png")
	if err != nil {
		log.Fatal(err)
	}
	img1, err := png.Decode(f1)
	if err != nil {
		log.Fatal(err)
	}
	filter1 := ebiten.FilterNearest
	// 把Image文件转成ebiten.Image文件，用于展示
	eImg1, _ := ebiten.NewImageFromImage(img1,filter1)

	var groundX int = 0;
	var groundY int = 437;
	for i :=1;i<5;i++ {
		op1 := &ebiten.DrawImageOptions{}
		op1.GeoM.Translate(float64(groundX), float64(groundY))   // 图像坐标
		groundX+=250
		// 在屏幕上展示出图片
		screen.DrawImage(eImg1, op1)

	}
}
